/*
 *  Copyright (c) 2022 李伟国
 *  online-judge is licensed under Mulan PSL v2.
 *  You can use this software according to the terms and conditions of the Mulan PSL v2.
 *  You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 *  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 *  See the Mulan PSL v2 for more details.
 */

package edu.platform.entity;

public class Runner {
    private String filePrefix;  // 文件前缀名
    private String fileSuffix;  // 文件后缀名
    private String language;  // 语言
    private String languageDir;  // 语言文件夹
    private String filePath;  // 测试源代码文件路径
    private Integer time;  // 限时
    private Integer memory;  // 内存
    private String mode;  // 测试模式
    private String type;  //接受结果的类型
    private Boolean deleteFile;  // 删除测试源代码
    private String judgePath;  // judge执行路径
    private String testDir;  // 测试文件夹
    private String codeResultDir;  // 代码结果的生成路径

    public Runner() {
        mode = "entire";
        type = "json";
        deleteFile = false;
        languageDir = "./language";
        memory = 2000000;
        time = 60*1000;
    }

    public Runner(String filePrefix, String fileSuffix, String language, String languageDir, String filePath, Integer time, Integer memory, String mode, String type, Boolean deleteFile, String judgePath, String testDir, String codeResultDir) {
        this.filePrefix = filePrefix;
        this.fileSuffix = fileSuffix;
        this.language = language;
        this.languageDir = languageDir;
        this.filePath = filePath;
        this.time = time;
        this.memory = memory;
        this.mode = mode;
        this.type = type;
        this.deleteFile = deleteFile;
        this.judgePath = judgePath;
        this.testDir = testDir;
        this.codeResultDir = codeResultDir;
    }

    public String getFilePrefix() {
        return filePrefix;
    }

    public Runner setFilePrefix(String filePrefix) {
        this.filePrefix = filePrefix;
        return this;
    }

    public String getFileSuffix() {
        return fileSuffix;
    }

    public Runner setFileSuffix(String fileSuffix) {
        this.fileSuffix = fileSuffix;
        return this;
    }

    public String getLanguage() {
        return language;
    }

    public Runner setLanguage(String language) {
        this.language = language;
        return this;
    }

    public String getLanguageDir() {
        return languageDir;
    }

    public Runner setLanguageDir(String languageDir) {
        this.languageDir = languageDir;
        return this;
    }

    public String getFilePath() {
        return filePath;
    }

    public Runner setFilePath(String filePath) {
        this.filePath = filePath;
        return this;
    }

    public Integer getTime() {
        return time;
    }

    public Runner setTime(Integer time) {
        this.time = time;
        return this;
    }

    public Integer getMemory() {
        return memory;
    }

    public Runner setMemory(Integer memory) {
        this.memory = memory;
        return this;
    }

    public String getMode() {
        return mode;
    }

    public Runner setMode(String mode) {
        this.mode = mode;
        return this;
    }

    public String getType() {
        return type;
    }

    public Runner setType(String type) {
        this.type = type;
        return this;
    }

    public Boolean getDeleteFile() {
        return deleteFile;
    }

    public Runner setDeleteFile(Boolean deleteFile) {
        this.deleteFile = deleteFile;
        return this;
    }

    public String getJudgePath() {
        return judgePath;
    }

    public Runner setJudgePath(String judgePath) {
        this.judgePath = judgePath;
        return this;
    }

    public String getTestDir() {
        return testDir;
    }

    public Runner setTestDir(String testDir) {
        this.testDir = testDir;
        return this;
    }

    public String getCodeResultDir() {
        return codeResultDir;
    }

    public Runner setCodeResultDir(String codeResultDir) {
        this.codeResultDir = codeResultDir;
        return this;
    }

    /**
     * 重写toString函数
     * @return 返回judge运行命令
     */
    @Override
    public String toString() {
        return  "python3 " + judgePath +
                " --language " + language +
                " --languageConfig " + languageDir +
                " --file " + filePrefix+fileSuffix +
                " --filePath " + filePath +
                " --time " + time +
                " --memory " + memory +
                " --mode " + mode +
                " --type " + type +
                " --deleteFile " + deleteFile +
                " --testDir " + testDir +
                " --codeResultDir " + codeResultDir;
    }
}
